Function.prototype._apply = function(context = window) {
    if(typeof this != 'function' || this == null) {
        throw new TypeError('error')
    }
    let args = [...arguments][1]
    context.fn = this
    let result = context.fn(args)
    delete context.fn
    return result
}

let obj = {
    name: '123',
    age: 12,
    myfun:function(a, b) {
        console.log(this.name + '年龄' + this.age + a + b);
    }
}
let obj1 = {
    name: '诚',
    age:18
}

obj.myfun._apply(obj1, ['good', 'Numberone'])
obj.myfun.apply(obj1, ['good', 'Numberone'])



Function.prototype.myapply = function(context = window, arr = []) {
    if(this == null || typeof this != 'function') {
        throw new Error('错误')
    }
    context[fn] = this
    let result = context[fn](...arr)
    delete context.fn
    return result
}
obj.myfun.myapply(obj1, ['good', 'Numberone'])


  foo.myapply(123,numArr)
  foo.myapply('123',numArr)
  foo.myapply(false,numArr)
  foo.myapply([],numArr)
